package com.mezz.bones.framework.mybatis.dynamic.provider;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class DataSourceInfoProviderConfiguration {

    /**
     * 当容器中没有DataSourceConfigLoader类型的Bean时，这个Bean才会被创建
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(DataSourceInfoProvider.class)
    public DataSourceInfoProvider defaultDataSourceConfigLoader() {
        //打个日志 提示引入该组件的项目需要实现该bean
        log.warn("请实现DataSourceInfoLoader接口，并配置到容器中");
        return new DefaultDataSourceInfoProviderImpl();
    }
}
